Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

307
Visualizações
Why is ESLint complaining about a syntax error when I can run my code fine in Node? "Parsing error: Unexpected token ="

I have looked around in Stackoverflow and the ESLint docs for an answer, but most are not what I need since they pertain to React.

I am using Node v14.17.0, and ESLint v7.32.0 as a dev dependency. I have the following piece of code.

class Service {
  constructor(){
    this.numbers = [1,2,3];
  }

  doAnotherThing = () => {
    console.log("I do the thing after 100 millis", this.numbers);
  }
  
  doSomething(){
    setTimeout(this.doAnotherThing, 100);
  }
}

let service = new Service();
service.doSomething();

Simply running node test.js runs the application fine and I get the expected result printed to STDOUT.

All sounds good, let me add ESLint and the eslint config file.

{
  "env": {
      "node": true,
      "mocha": true
  },
  "extends": "eslint:recommended",
  "parserOptions": {
      "ecmaVersion": "latest"
  },
}

Now run when I run eslint on the file, I get the following error.

/test.js
  2:10  error  Parsing error: Unexpected token =

Keep in mind I am NOT using Babel or any transpiling, so do I need to specify a variable or something in the config? Why is this error happening and why does installing @babel/eslint-parser solve the issue? I am not using Babel at all. Is this a limit to ESLint or simply something I don't understand?

Using a regular method(){} does NOT work and is not the solution since I lose the this.number value. See: https://jsfiddle.net/0crpx6bv

Reading around I see a lot of React and NONE Node.js solutions. This is plain Node without Babel and not in React.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda